Skip to content

Conversation

@Keno
Copy link
Member

@Keno Keno commented Jun 9, 2025

inert is mostly used in lowering. As far as I can tell, there is precisely one place in the flisp parser that produces it:

https://github.com/JuliaLang/julia/blob/d6b3669621ceb18aea693d8544b2c38870d289ad/src/julia-parser.scm#L1259

However, we do not insert and inert there in JuliaSyntax, instead preferring to automatically quote the rhs of a . head in expr conversion:

args[2] = QuoteNode(a2)

As a result, (and as code coverage complains), the syntax head is unused and should be removed here. However, it should probably then be added back in JuliaLowering.

@Keno Keno requested review from JeffBezanson and mlechu June 9, 2025 20:34
@JeffBezanson
Copy link
Member

Yes, I think this is fine, assuming the implementation of quasi-quote knows how to handle the implicit quoting in ., which I suppose it must.

@Keno
Copy link
Member Author

Keno commented Jun 9, 2025

👍 I'm assuming JuliaLowering must understand this and for flisp lowering, QuoteNode, gets turned into (inert), so what expr.jl is doing here will look the same to flisp lowering.

@mlechu
Copy link
Member

mlechu commented Jun 9, 2025

Looks fine to me, though I hope for a day these can be in Base

@Keno
Copy link
Member Author

Keno commented Jun 9, 2025

though I hope for a day these can be in Base

Isn't QuoteNode in the AST exactly this?

@Keno
Copy link
Member Author

Keno commented Jun 9, 2025

Or were you saying you want syntax for it?

@mlechu
Copy link
Member

mlechu commented Jun 9, 2025

Just syntax, and not wanting to juggle code between JuliaLowering and JuliaSyntax

`inert` is mostly used in lowering. As far as I can tell, there
is precisely one place in the flisp parser that produces it:

https://github.com/JuliaLang/julia/blob/d6b3669621ceb18aea693d8544b2c38870d289ad/src/julia-parser.scm#L1259

However, we do not insert and `inert` there in JuliaSyntax, instead preferring
to automatically quote the rhs of a `.` head in expr conversion:

https://github.com/JuliaLang/JuliaSyntax.jl/blob/eceaa39706c6ecc3ef496613096216625dba558e/src/expr.jl#L310

As a result, (and as code coverage complains),  the syntax head is
unused and should be removed here. However, it should probably
then be added back in JuliaLowering.
@Keno Keno merged commit ebfaf96 into main Jun 12, 2025
36 checks passed
@Keno Keno deleted the kf/rminert branch June 12, 2025 02:32
@mlechu
Copy link
Member

mlechu commented Jul 8, 2025

We might want to revert this. I didn't know at the time that JuliaLowering uses expr.jl for (pre-lowering) SyntaxTree->Expr conversion.

K"inert" won't be in the tree if we got it from normal parsing, but if it's been through macro expansion (or is from expr->syntaxtree, depending on whether we end up back-converting QuoteNodes) it can show up.

@Keno
Copy link
Member Author

Keno commented Jul 9, 2025

It feels like we should possibly introduce some proper layering here then so that JuliaLowering can add additional forms - it seems weird that the conversion logic for such forms should go into the parser. Unless we think that inert is the only case and there will never be any others.

@mlechu
Copy link
Member

mlechu commented Jul 9, 2025

Maybe. JuliaSyntax.node_to_expr is only defined on pre-lowering trees, so JuliaLowering shouldn't be adding new forms. I was thinking that all pre-lowering (post-parsing up to post-macroexpand) trees should allow the same set of forms, so node_to_expr being defined in one piece is best.

On the other hand, I'll probably be setting up a JuliaLowering layer to node_to_expr anyway for macro hygiene (i.e. do a subset of the gynsyming we do normally) since that doesn't make sense to put in the parser. We could also deal with K"inert" there, but other than requiring gensyms, I don't think the post-parse and post-macroexpand tree definitions will (or should) drift too far apart.

cc @c42f in case you have opinions

@c42f
Copy link
Member

c42f commented Jul 10, 2025

Thanks for the mention @mlechu.

I didn't see this go past when it was proposed and I was out of action.

Personally I feel like K"inert" is a weird middle ground - something which should eventually have actual "offical syntax" - even if it's just a Base.@inert macro which emits K"inert". Plain quote (not quasiquote) is a pretty fundamental thing to want, really. Actually, if you look in JuliaLowering I've already had a crack at prototyping @inert (unclear if it's correct yet).

Anyway, so it's probably not very harmful to have removed K"inert" for now, but I kinda feel like it does belong in JuliaSyntax even though we technically don't emit it right now.

The issue of dealing with hygiene is separate - as you say that's definitely a lowering problem and shouldn't intrude on JuliaSyntax stuff so we do need a way to deal with that and I'm not 100% sure what is cleanest but I'm thinking about it.

c42f pushed a commit to JuliaLang/julia that referenced this pull request Oct 17, 2025
`inert` is mostly used in lowering. As far as I can tell, there
is precisely one place in the flisp parser that produces it:

https://github.com/JuliaLang/julia/blob/d6b3669621ceb18aea693d8544b2c38870d289ad/src/julia-parser.scm#L1259

However, we do not insert and `inert` there in JuliaSyntax, instead preferring
to automatically quote the rhs of a `.` head in expr conversion:

https://github.com/JuliaLang/JuliaSyntax.jl/blob/5f64351f4546c0e782760eb9e835fac89644bd44/src/expr.jl#L310

As a result, (and as code coverage complains),  the syntax head is
unused and should be removed here. However, it should probably
then be added back in JuliaLowering.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants